<template>
	<view class="pb-safe-area">
		<view class="p-4 flex flex-column grid-gap-4">
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/user/account/bind', true)" v-if="UserStore.hasLogin()">
				<text class="flex-1 h9 text-grey">账户安全</text>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2" @tap="clearCache">
				<text class="flex-1 h9 text-grey">清除缓存</text>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/article/content?alias=user_agreement')">
				<text class="flex-1 h9 text-grey">用户协议</text>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/article/content?alias=privacy')">
				<text class="flex-1 h9 text-grey">隐私政策</text>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>
			<view class="flex bg-white rounded-4 p-4 flex-center grid-gap-2"
				@tap="$page.open('/pages/article/content?alias=about')">
				<text class="flex-1 h9 text-grey">关于我们</text>
				<uni-icons type="right" color="var(--xl-placeholder)"></uni-icons>
			</view>

			<view class="flex" v-if="UserStore.hasLogin()">
				<button class="flex-1 btn-dark-light-9 btn-round" @click="outLogin">退出账号</button>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref, nextTick } from 'vue';
import { onLoad, onUnload } from '@dcloudio/uni-app';
import { useStatusStore, useUserStore, useRefs } from "@/stores";
import { $page, $api, $http, $message,useStorage } from "@/utils";
const StatusStore = useStatusStore();
const { WEBCONFIG } = useRefs(StatusStore);
const UserStore = useUserStore();
const { USERINFO } = useRefs(UserStore);
const clearCache = () => {
	$message.success('清除成功');
	StatusStore.clear();
	// #ifdef H5
	setTimeout(() => {
		window.location.reload();
	}, 500)
	// #endif
}
const outLogin = () => {
	uni.showModal({
		title: '提示',
		content: '是否退出登录？',
		success: (res: any) => {
			if (res.confirm) {
				UserStore.clearUserInfo();
				StatusStore.clear();
				useStorage().remove('finance');
				$page.re('/pages/index/index');
			}
		}
	})
}
</script>
